import requests
# 111.13.101.208
file_name = "api_server.scv"
ip = input("请输入要查询的ip:")
res = requests.get(f"https://ip.taobao.com/outGetIpInfo?accessKey=alibaba-inc&ip={ip}")
res.encoding = 'utf-8'
json_res = res.json()
print(f"country:{json_res['data']['country']},region:{json_res['data']['region']},isp:{json_res['data']['isp']}")
try:
    with open(file_name, "a", encoding="utf-8") as fp:
        fp.write(f"ip:{ip},country:{json_res['data']['country']},region:{json_res['data']['region']},isp:{json_res['data']['isp']}"+"\n")
except Exception as ex:
    print("ex")
